﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Admin_frChitietDT : System.Web.UI.Page
{
    clsCauHoi clsch = new clsCauHoi();
    clsTaoDeThi clstaodt = new clsTaoDeThi();
    clsDecon clsdecon = new clsDecon();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string mach = ((Label)GridView1.SelectedRow.FindControl("lblmach")).Text.ToString();
        string madt = Request.QueryString["madt"];
        GridView2.DataSource = clsch.dsCHthaythe(mach,madt);
        GridView2.DataBind();
        
    }
    protected void btnThay_Click(object sender, EventArgs e)
    {
        string madt = Request.QueryString["madt"];
        if (clsdecon.ktDataodecon(madt))
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Alert", "alert('Đề này đã tạo đề con nên không được phép sửa đổi.');", true);
        }
        else
        {
            string machLeft = ((Label)GridView1.SelectedRow.FindControl("lblmach")).Text.ToString();
            string machRight = ((Label)GridView2.SelectedRow.FindControl("lblmachright")).Text.ToString();

            clstaodt.hoandoiCH(machLeft, machRight, madt);
            GridView1.DataBind();
            GridView2.DataBind();

        }
    }
}
